#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	vector<int> v(n + 1);
	for (int i = 0; i < n; i++)
	{
		v[i] = i + 1;
	}
	int count = 0, temp = 0;
	for (int i = 0; count != n; i++)
	{
		if (i == n)
		{
			i = 0;
		}
		if (v[i] != 0)
		{
			temp++;
		}
		if (temp == m)
		{
			temp = 0;
			cout << v[i] << ' ';
			v[i] = 0;
			count++;
		}
	}

	return 0;
}